package com.av.bcacc.kotlinpai

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_kotlin_main.*

class KotlinMainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_kotlin_main)
        button.setOnClickListener{
            Toast.makeText(this,"kotlinToast",Toast.LENGTH_LONG).show()
        }
        button2.setOnClickListener {
            var intent= Intent(this,ToSecondActivity::class.java)
            startActivity(intent)
        }

    }

    override fun onCreateOptionsMenu(menu: Menu?): Boolean {
        menuInflater.inflate(R.menu.main,menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when(item.itemId){
            R.id.add_item -> Toast.makeText(this,"addItem",Toast.LENGTH_LONG).show()
            R.id.remove_item -> Toast.makeText(this,"removeItem",Toast.LENGTH_LONG).show()
        }
        return true
    }
}
